{layout name="layout"}
<div id="page-title">
    <h1 class="page-header text-overflow"></h1>
</div>
<style type="text/css">
    .active-mao,.active-link{
        background-color: #eee;
    }
</style>
<div class="row">
    <div class="col-md-10 col-md-offset-1">
        {if $project}
        <div class="col-sm-3 col-md-3 col-lg-3">
            <div class="panel">
                <div class="panel-heading bg-gray-light">
                    <h3 class="panel-title text-dark">{$project.classifyname}</h3>
                </div>
                    <div class="nano-content">
                        <ul id="mainnav-menu" class="list-group nav">
                            {if isset($project.categories)&&!empty($project.categories)}
                                {foreach $project.categories as $category}
                                <li class="{if $category['active'] =='true'}active-link{/if}"><a href="/apilist/{$project.id}/{$category.id}.html" class="text-primary"><span class="menu-title">{$category.classifyname}</span></a></li>
                                {/foreach}
                            {/if}
                        </ul>
                </div>
            </div>
        </div>
        <div class="col-sm-9 col-md-9 col-lg-9">
            {if $project.apis}
            <div class="panel">
                {foreach $project.apis as $key=>$api}
                    <h4 id="api_id_{$api.id}" class="panel-title text-dark">{$key+1}.{$api.apiname}&nbsp;&nbsp;<span class="label label-info">{$api.version}</span></h4>
                    <div  class="table-responsive pad-hor">
                        <table class="table">
                            <tbody>
                                <tr>
                                    <td class="text-semibold">简介</td>
                                    <td>{$api.description}</td>
                                </tr>
                                <tr>
                                    <td class="text-semibold">本地接口地址</td>
                                    <td>{$api.gateway}</td>
                                </tr>
                                <tr>
                                    <td class="text-semibold">请求方式</td>
                                    <td>{$api.param.type}</td>
                                </tr>
                                <tr>
                                    <td class="text-semibold">header参数</td>
                                    <td></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="table-responsive pad-hor">
                        <table class="table">
                            <thead class="bg-gray-light">
                                <tr>
                                    <th class="text-left">字段名称</th>
                                    <th class="text-left">字段类型</th>
                                    <th class="text-left">是否必须</th>
                                    <th class="text-left">描述</th>
                                    <th class="text-left">默认值</th>
                                </tr>
                            </thead>
                            <tbody>
                            {if $api.param.header.0.field}
                                {foreach $api.param.header as $header}
                                <tr>
                                    <td>{$header.field}</td>
                                    <td>{$header.type}</td>
                                    <td>{if $header.must =='true'}是{else}否{/if}</td>
                                    <td>{$header.des}</td>
                                    <td>{$header.default}</td>
                                </tr>
                                {/foreach}
                            {else}
                                <tr>
                                    <td colspan="4" class="text-center text-bold">不需要参数</td>
                                </tr>
                            {/if}
                            </tbody>
                        </table>
                    </div>
                    <div class="table-responsive pad-hor">
                        <table class="table">
                        <tbody>
                            <tr>
                                <td class="text-semibold">{$api.param.type}请求参数</td><td></td>
                            </tr>
                        </tbody>
                        </table>
                    </div>
                    <div class="table-responsive pad-hor">
                        <table class="table">
                            <thead class="bg-gray-light">
                                <tr>
                                    <th class="text-left">字段名称</th>
                                    <th class="text-left">字段类型</th>
                                    <th class="text-left">是否必须</th>
                                    <th class="text-left">描述</th>
                                    <th class="text-left">默认值</th>
                                </tr>
                            </thead>
                            <tbody>
                                {if $api['param']['request'][$api.param.type]}
                                    {foreach $api['param']['request'][$api.param.type] as $param}
                                    <tr>
                                        <td>{$param.field}</td>
                                        <td>{$param.type}</td>
                                        <td>{if $param.must =='true'}是{else}否{/if}</td>
                                        <td>{$param.des}</td>
                                        <td>{$param.default}</td>
                                    </tr>
                                    {/foreach}
                                {else}
                                    <tr>
                                        <td colspan="4" class="text-center text-bold">不需要参数</td>
                                    </tr>
                                {/if}
                            </tbody>
                        </table>
                    </div>
                    <div class="table-responsive pad-hor">
                        <table class="table">
                        <tbody>
                            <tr>
                                <td class="text-semibold">响应参数</td><td></td>
                            </tr>
                        </tbody>
                        </table>
                    </div>
                    <div class="table-responsive pad-hor">
                        <table class="table">
                            <thead class="bg-gray-light">
                                <tr>
                                    <th class="text-left">字段名称</th>
                                    <th class="text-left">字段类型</th>
                                    <th class="text-left">是否必须</th>
                                    <th class="text-left">描述</th>
                                    <th class="text-left">默认值</th>
                                </tr>
                            </thead>
                            <tbody>
                                {if $api['param']['response'][$api.param.type]}
                                    {foreach $api['param']['response'][$api.param.type] as $param}
                                    <tr>
                                        <td>{$param.field}</td>
                                        <td>{$param.type}</td>
                                        <td>{if $param.must =='true'}是{else}否{/if}</td>
                                        <td>{$param.des}</td>
                                        <td>{$param.default}</td>
                                    </tr>
                                    {/foreach}
                                {else}
                                    <tr>
                                        <td colspan="4" class="text-center text-bold">不需要参数</td>
                                    </tr>
                                {/if}
                            </tbody>
                        </table>
                    </div>
                    <div class="table-responsive pad-hor">
                        <table class="table">
                        <tbody>
                            <tr>
                                <td class="text-semibold">返回示例</td><td></td>
                            </tr>
                            <tr>
                                <td colspan="2" class="text-semibold"><pre>{$api.goback}</pre></td>
                            </tr>
                        </tbody>
                        </table>
                    </div>
                    <div class="table-responsive pad-hor">
                        <table class="table">
                        <tbody>
                            <tr>
                                <td class="text-semibold">响应错误码</td><td></td>
                            </tr>
                        </tbody>
                        </table>
                    </div>
                    <div class="table-responsive pad-hor">
                        <table class="table">
                            <thead class="bg-gray-light">
                                <tr>
                                    <th class="text-left">错误码</th>
                                    <th class="text-left">描述</th>
                                </tr>
                            </thead>
                            <tbody>
                                {if $api['param']['statuscode']}
                                {foreach $api['param']['statuscode'] as $param}
                                    <tr>
                                        <td>{$param.status}</td>
                                        <td>{$param.des}</td>
                                    </tr>
                                {/foreach}
                                {else}
                                    <tr>
                                        <td colspan="2" class="text-center text-bold">未添加错误码</td>
                                    </tr>
                                {/if}
                            </tbody>
                        </table>
                    </div>
                {/foreach}
            </div>
            {else}
            <div class="panel text-center">
                <img width="200" height="200" src="__IMG__/error.png">
                <h4 class="panel-title text-dark">该分类下无API信息</h4>
            </div>
            {/if}
        </div>
        {if $project.apis}
        <div class="col-sm-2 col-md-2 col-lg-2" style="z-index: 999;position: fixed;left: 82%;">
            <div class="panel">
                <div id="nav-scroll" class="nano-content">
                    <ul id="mainnav-menu" class="list-group nav">
                        {foreach $project.apis as $key=>$api}
                        {if $key == '0'}
                            <li class="mao-click active-mao"><a href="#api_id_{$api.id}" class="text-primary"><span class="menu-title">{$key+1}.{$api.apiname}</span></a></li>
                        {else}
                            <li class="mao-click"><a href="#api_id_{$api.id}" class="text-primary"><span class="menu-title">{$key+1}.{$api.apiname}</span></a></li>
                        {/if}
                        {/foreach}
                    </ul>
                </div>
            </div>
        </div>
        {/if}
        {/if}
    </div>
</div>
<script type="text/javascript">
    $('.mao-click').click(function(){
        $('.mao-click').removeClass('active-mao');
        $(this).addClass('active-mao');
    });
    
</script>